package graphics.rendering;

import graphics.GraphicsManager;

import org.lwjgl.opengl.GLContext;

/** Provide facilities for matching graphics implementations with hardware. */
public class GraphicsFactory {
	
	/**
	 * Returns a GraphicsPipeline which is supported on
	 * the current system.
	 * @return GraphicsPipeline
	 * @throws Exception 
	 */
	public static GraphicsPipeline create(GraphicsManager manager) throws Exception {
		GraphicsPipeline pipeline;
		if(checkCapabilities()) {
			// Forward compatibility mode
			pipeline = new CorePipeline(manager);
		} else {
			// Legacy mode
			pipeline = new LegacyPipeline(manager);
		}
		return pipeline;
	}
	
	/** Return true if the core profile pipeline has all the required features. */
	public static boolean checkCapabilities() {
		if(!GLContext.getCapabilities().GL_ARB_vertex_buffer_object) {
			return false;
		}
		return true;
	}
}
